package shiyan;
import java.util.Scanner;
public class Triangle {
    public static void main(String[] args) {
        int num;
        System.out.println("请输入三角形层数：");
        Scanner sc=new Scanner(System.in);
        num=sc.nextInt();
        for (int i=1;i<=num;i++){
            for (int j=1;j<=num-i;j++){
                System.out.print(" ");
            }
            for (int k=1;k<=i;k++){
                if (i%2==0){
                    System.out.print(2+" ");
                }
                else{
                    System.out.print(1+" ");
                }
            }
            System.out.println();
        }
        System.out.println("倒三角");
        for (int i=num;i>=1;i--){
            for (int j=1;j<=num-i;j++){
                System.out.print(" ");
            }
            for (int k=1;k<=i;k++){
                if (i%2==0){System.out.print(2+" ");}
                else{System.out.print(1+" ");}
            }
            System.out.println();
        }
    }
}
